def parsed_ast(token_list):
    """
    Recursive parsing of AST.
    """
    ts = token_list
    token = ts[0]
    del ts[0]
    if token == '[':
        exp = []
        while ts[0] != ']':
            t = parsed_ast(ts)
            exp.append(t)
        # Loop ends, remove the trailing ']'
        del ts[0]
        return exp
    else:
        # token needs to be processed further or returned as-is
        return token


def main_parsed_ast():
    tokens = ['[', '+', 12, '[', '-', 23, 45, ']', ']']
    expected_ast = ['+', 12, ['-', 23, 45]]
    ast = parsed_ast(tokens)
    print('Recursive parse result:', ast)
    assert ast == expected_ast


if __name__ == '__main__':
    main_parsed_ast()
